﻿using System.Collections.Generic;
using System.Linq;
using Model;

namespace ReportBrowser.ViewModel
{
    internal class MessageContainerNamespaceViewModel : NamespaceViewModel
    {
        #region Lifecycle

        public MessageContainerNamespaceViewModel(Namespace model)
            : base(model) { }

        #endregion Lifecycle

        #region Properties

        public static bool IsCummulative { get; set; }

        public IEnumerable<MessageViewModel> Messages
        {
            get
            {
                return MessageViewModel.FindByNamespace(this.Model.Name, IsCummulative);
            }
        }

        public double Weight
        {
            get
            {
                return this.Messages.Sum(mvm => mvm.Weight);
            }
        }

        #endregion Properties

        #region Methods

        public static bool HasMessages(Namespace model)
        {
            return MessageViewModel.IsAnyByNamespace(model.Name, IsCummulative);
        }

        #endregion Methods
    }
}
